/*
 *  crossScene.h
 *  opencvExample
 *
 *  Created by ycam on 11/03/04.
 *  Copyright 2011 __MyCompanyName__. All rights reserved.
 *
 */


#pragma once
#include "ofMain.h"
#include "basePattern.h"

class crossScene : public basePattern{
public:
	void setup(){
		allocate();
		for (int i=0; i<w+h; i++) {
			tmpval = 0;
		}
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				//				unsigned char tmpval = j < i * (w/h) ? 255 * j/(float)w :0 ;	
//				float posNormalizeX = j / (float) w;
//				float posNormalizeY = i / (float) h;
				float gp = w / (float) h;
				if (j>=gp*i && j<=gp*(i+1)) {
					tmpval = maxGray;
				}
				
//				if ( (w - 1 - j)>=gp*i && j<=gp*(i+1)) {
//					tmpval = maxGray;
//				}
				
//				if (j >= gp*(h - i - 1 - 1) && j <= gp*((h - i - 1)) ) {
//					tmpval = maxGray;
//				}
				else{
					tmpval = 0;
				}
				currentColorPixels[(i*w+j)*3 + 0] = tmpval;
				currentColorPixels[(i*w+j)*3 + 1] = tmpval;
				currentColorPixels[(i*w+j)*3 + 2] = tmpval;		
			}
		}
	}
	void update(){
		currentColorImage.setFromPixels(currentColorPixels, w, h);	
		count++;
	}
	void setupWhenPatternChanged(){
		count = 0;
	}
	int count;
	char tmpval;
};